Conditionally Setting HTTP Response Header

Conditionally Setting HTTP Response Header

am 15.03.2010 13:50:36 von Anurag Kapur

--00032555b1f6d7a9e00481d653cc
Content-Type: text/plain; charset=ISO-8859-1

Hello,

I am looking for some help to set HTTP response headers conditionally. I
have a setup where HTTPD sits in front of Tomcat and proxies requests to it.

*Problem Statement*
Set a Cache-Control max-age directive in the HTTP response header through
HTTPD if it doesn't already exist. In addition if HTTPD after detecting that
the directive is not already set in the response header, it should set one
depending on the response mime-type.

Example:
HTTPD proxies a request to tomcat -> Tomcat processes the request and send
back the response to HTTPD -> HTTPD checks if Cache-Control max-age
directive is set in the response header. If present it does no changes to
the response header and simply forwards the response back to the user.
However, if the Cache-Control max-age directive is not present it sets one
depending on the response mime type (say max-age=900 for text/html and
max-age=1800 for image/gif)
*
*
*System Info*
$ apachectl -version
Server version: Apache/2.2.9 (Unix)
Server built: Sep 12 2008 16:23:39

$ uname -a
SunOS vm-sol10-45 5.10 Generic_127128-11 i86pc i386 i86p

*What I Have Tried*
I have been trying to work with mod_setenvif module to start but have not
made any progress and thus seeking your help.

Any inputs would be highly appreciated.

Regards
Anurag
*
*----------------------------------------------------------- -------
Anurag Kapur
Associate - Technology,
Sapient Corporation.

http://www.linkedin.com/in/anuragkapur

http://www.google.com/profiles/anuragkapur
------------------------------------------------------------ ------

--00032555b1f6d7a9e00481d653cc
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,


I am looking for some help to set HTTP response h=
eaders conditionally. I have a setup where HTTPD sits in front of Tomcat an=
d proxies requests to it.

Problem Statement=

Set a Cache-Control max-age directive in the HTTP response header thro=
ugh HTTPD if it doesn't already exist. In addition if HTTPD after detec=
ting that the directive is not already set in the response header, it shoul=
d set one depending on the response mime-type.


Example:
HTTPD proxies a request to tomcat -&=
gt; Tomcat processes the request and send back the response to HTTPD -> =
HTTPD checks if Cache-Control max-age directive is set in the response head=
er. If present it does no changes to the response header and simply forward=
s the response back to the user. However, if the Cache-Control max-age dire=
ctive is not present it sets one depending on the response mime type (say m=
ax-age=3D900 for text/html and max-age=3D1800 for image/gif)


System Info
ay: inline !important; ">$ apachectl -version=A0
=3D"display: inline !important; ">
">Server version: Apache/2.2.9 (Unix)=A0

display: inline !important; ">
S=
erver built: =A0 Sep 12 2008 16:23:39=A0
tyle=3D"display: inline !important; ">
important; ">
!important; ">
splay: inline !important; ">
$ uname -a
SunOS vm-sol10-45 5.10 Generic_12712=
8-11 i86pc i386 i86p

What I Have Tried >
I have been trying to work with mod_setenvif module to start but have=
not made any progress and thus seeking your help.


Any inputs would be highly appreciated.

<=
/div>
Regards
Anurag

-----=
------------------------------------------------------------ -
Anurag Kap=
ur

Associate - Technology,
Sapient Corporation.

w.linkedin.com/in/anuragkapur">http://www.linkedin.com/in/an uragkapur r>
http://www.goo=
gle.com/profiles/anuragkapur


------------------------------------------------------------ ------



--00032555b1f6d7a9e00481d653cc--

Re: Conditionally Setting HTTP Response Header

am 15.03.2010 14:15:37 von Baljeet Nijjhar

--000e0ce029f64aa21f0481d6ad43
Content-Type: text/plain; charset=ISO-8859-1

Hi Anurag
I have had the exact same problem and posted in
http://www.gossamer-threads.com/lists/apache/users/382031?pa ge=last
You can use ExpiresDefault/ExpiresByType (this adds both an Expires and
Cache-Control: max-age header to simultaneously support HTTP 1.0 and HTTP
1.1) or use LocationMatch. For example, I could distinguish between static
content requests (requests to *.gif) vs dynamic content requests
(requests to *.jsp or *.do for a Struts application) using the
LocationMatch. I couldn't find a way of using LocationMatch to work with the
content-type of the response, which was what I needed for file download
requests. Nor could I find a way of checking whether the header was set,
before setting it. (I'm still asking the question).
In the end, I have set the values using e.g. servlet filters in my
application code.
thanks, Balj.

On Mon, Mar 15, 2010 at 12:50 PM, Anurag Kapur wrote:

> Hello,
>
> I am looking for some help to set HTTP response headers conditionally. I
> have a setup where HTTPD sits in front of Tomcat and proxies requests to it.
>
> *Problem Statement*
> Set a Cache-Control max-age directive in the HTTP response header through
> HTTPD if it doesn't already exist. In addition if HTTPD after detecting that
> the directive is not already set in the response header, it should set one
> depending on the response mime-type.
>
> Example:
> HTTPD proxies a request to tomcat -> Tomcat processes the request and send
> back the response to HTTPD -> HTTPD checks if Cache-Control max-age
> directive is set in the response header. If present it does no changes to
> the response header and simply forwards the response back to the user.
> However, if the Cache-Control max-age directive is not present it sets one
> depending on the response mime type (say max-age=900 for text/html and
> max-age=1800 for image/gif)
> *
> *
> *System Info*
> $ apachectl -version
> Server version: Apache/2.2.9 (Unix)
> Server built: Sep 12 2008 16:23:39
>
> $ uname -a
> SunOS vm-sol10-45 5.10 Generic_127128-11 i86pc i386 i86p
>
> *What I Have Tried*
> I have been trying to work with mod_setenvif module to start but have not
> made any progress and thus seeking your help.
>
> Any inputs would be highly appreciated.
>
> Regards
> Anurag
> *
> *----------------------------------------------------------- -------
> Anurag Kapur
> Associate - Technology,
> Sapient Corporation.
>
> http://www.linkedin.com/in/anuragkapur
>
> http://www.google.com/profiles/anuragkapur
> ------------------------------------------------------------ ------
>

--000e0ce029f64aa21f0481d6ad43
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi Anurag

I=A0have had the exact same problem and posted in w.gossamer-threads.com/lists/apache/users/382031?page=3Dlast ">http://www.go=
ssamer-threads.com/lists/apache/users/382031?page=3Dlast

You can=A0use ExpiresDefault/ExpiresByType (this adds both an Expires =
and Cache-Control: max-age header to simultaneously support HTTP 1.0 and HT=
TP 1.1) or use LocationMatch. For example, I could distinguish between stat=
ic content requests (requests=A0to *.gif) vs dynamic content requests (requ=
ests=A0to *.jsp or *.do for a Struts application) using the LocationMatch.=
=A0I couldn't find a way of using LocationMatch to=A0work with=A0the co=
ntent-type of the response, which was what I needed for file download reque=
sts. Nor could I find a way of checking whether the header was set, before =
setting it. (I'm still asking the question).


In the end, I have set the values using e.g.=A0servlet filters in my a=
pplication code.

thanks, Balj.


On Mon, Mar 15, 2010 at 12:50 PM, Anurag Kapur <=
span dir=3D"ltr"><anuragkapur@g=
mail.com
> wrote:

px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hello,=20


I am looking for some help to set HTTP response headers conditionally.=
I have a setup where HTTPD sits in front of Tomcat and proxies requests to=
it.



Problem Statement

Set a Cache-Control max-age directive in the HTTP response header thro=
ugh HTTPD if it doesn't already exist. In addition if HTTPD after detec=
ting that the directive is not already set in the response header, it shoul=
d set one depending on the response mime-type.




Example:

HTTPD proxies a request to tomcat -> Tomcat processes the request a=
nd send back the response to HTTPD -> HTTPD checks if Cache-Control max-=
age directive is set in the response header. If present it does no changes =
to the response header and simply forwards the response back to the user. H=
owever, if the Cache-Control max-age directive is not present it sets one d=
epending on the response mime type (say max-age=3D900 for text/html and max=
-age=3D1800 for image/gif)




System Info


$ apachectl -version=A0
v>


Server version: Apache/2.2.9 (Uni=
x)=A0




Server built: =A0 Sep 12 2008 16:=
23:39=A0









$ uname -a
>
SunOS vm-sol10-45 5.10 Generic_127128-11 i86pc i386 i86p



What I Have Tried

I have been trying to work with mod_setenvif module to start but have =
not made any progress and thus seeking your help.



Any inputs would be highly appreciated.



Regards

Anurag


---------------------------------------------=
---------------------
Anurag Kapur
Associate - Technology,
Sapient=
Corporation.

get=3D"_blank">http://www.linkedin.com/in/anuragkapur


">http://www.google.com/profiles/anuragkapur
-----------------------=
-------------------------------------------
>

--000e0ce029f64aa21f0481d6ad43--

Re: Conditionally Setting HTTP Response Header

am 15.03.2010 14:29:46 von Anurag Kapur

Thanks Balj.

Unfortunately using a servlet filter will not serve my purpose. In my
system, some requests are proxied from HTTPD to Tomcat while others
are served directly by HTTPD. Thus, I am looking for something in the
HTTPD layer that can check if the header is already set and then take
action accordingly.

I am quite sure SetEnvIf directive in conjunction with Header set
directive can work here. However, I have not managed to get it working
after quite a few tries. Thus I am polling this group to know if
someone has already implemented somthing similar.

Regards


On 3/15/10, Baljeet Nijjhar wrote:
> Hi Anurag
> I have had the exact same problem and posted in
> http://www.gossamer-threads.com/lists/apache/users/382031?pa ge=last
> You can use ExpiresDefault/ExpiresByType (this adds both an Expires and
> Cache-Control: max-age header to simultaneously support HTTP 1.0 and HTTP
> 1.1) or use LocationMatch. For example, I could distinguish between static
> content requests (requests to *.gif) vs dynamic content requests
> (requests to *.jsp or *.do for a Struts application) using the
> LocationMatch. I couldn't find a way of using LocationMatch to work with the
> content-type of the response, which was what I needed for file download
> requests. Nor could I find a way of checking whether the header was set,
> before setting it. (I'm still asking the question).
> In the end, I have set the values using e.g. servlet filters in my
> application code.
> thanks, Balj.
>
> On Mon, Mar 15, 2010 at 12:50 PM, Anurag Kapur wrote:
>
>> Hello,
>>
>> I am looking for some help to set HTTP response headers conditionally. I
>> have a setup where HTTPD sits in front of Tomcat and proxies requests to
>> it.
>>
>> *Problem Statement*
>> Set a Cache-Control max-age directive in the HTTP response header through
>> HTTPD if it doesn't already exist. In addition if HTTPD after detecting
>> that
>> the directive is not already set in the response header, it should set one
>> depending on the response mime-type.
>>
>> Example:
>> HTTPD proxies a request to tomcat -> Tomcat processes the request and send
>> back the response to HTTPD -> HTTPD checks if Cache-Control max-age
>> directive is set in the response header. If present it does no changes to
>> the response header and simply forwards the response back to the user.
>> However, if the Cache-Control max-age directive is not present it sets one
>> depending on the response mime type (say max-age=900 for text/html and
>> max-age=1800 for image/gif)
>> *
>> *
>> *System Info*
>> $ apachectl -version
>> Server version: Apache/2.2.9 (Unix)
>> Server built: Sep 12 2008 16:23:39
>>
>> $ uname -a
>> SunOS vm-sol10-45 5.10 Generic_127128-11 i86pc i386 i86p
>>
>> *What I Have Tried*
>> I have been trying to work with mod_setenvif module to start but have not
>> made any progress and thus seeking your help.
>>
>> Any inputs would be highly appreciated.
>>
>> Regards
>> Anurag
>> *
>> *----------------------------------------------------------- -------
>> Anurag Kapur
>> Associate - Technology,
>> Sapient Corporation.
>>
>> http://www.linkedin.com/in/anuragkapur
>>
>> http://www.google.com/profiles/anuragkapur
>> ------------------------------------------------------------ ------
>>
>

--
Sent from my mobile device

------------------------------------------------------------ ------
Anurag Kapur
Associate - Technology,
Sapient Corporation.

+44 (0) 7514 996 586

http://www.linkedin.com/in/anuragkapur

http://www.google.com/profiles/anuragkapur
------------------------------------------------------------ ------

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Conditionally Setting HTTP Response Header

am 15.03.2010 15:12:26 von Eric Covener

> I have been trying to work with mod_setenvif module to start but have not
> made any progress and thus seeking your help.

Show us what you have, and what it does.

--
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Conditionally Setting HTTP Response Header

am 15.03.2010 15:19:57 von Anurag Kapur

--0015175cb4ba6201540481d79367
Content-Type: text/plain; charset=ISO-8859-1

I have been trying configurations like the following:

SetEnvIf response Cache-Control !"^max-age*$"
test=ThisShouldDisplayInXwsField
Header append X-ws test

With the above, as a first step I was trying to test if I can detect the
presence of Cach-Control max-age field in the Response header. What I
expected was, if response header had Cache-Control max-age field, then the
X-ws field would show the string 'ThisShouldDisplayInXwsField'. But I could
not see it set even though max-age was present in the header.

I know these are not complete, but I as the first step, I was trying to get
these to work.

-Anurag

On Mon, Mar 15, 2010 at 2:12 PM, Eric Covener wrote:

> > I have been trying to work with mod_setenvif module to start but have not
> > made any progress and thus seeking your help.
>
> Show us what you have, and what it does.
>
> --
> Eric Covener
> covener@gmail.com
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

--0015175cb4ba6201540481d79367
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I have been trying configurations like the following:


iv>SetEnvIf response Cache-Control !"^max-age*$" test=3DThisShoul=
dDisplayInXwsField
Header append X-ws test

iv>
With the above, as a first step I was trying to test if I can detect the pr=
esence of Cach-Control max-age field in the Response header. What I expecte=
d was, if response header had Cache-Control max-age field, then the X-ws fi=
eld would show the string 'ThisShouldDisplayInXwsField'. But I coul=
d not see it set even though max-age was present in the header.

I know these are not complete, but I as the first=
step, I was trying to get these to work.

-Anurag<=
/div>

On Mon, Mar 15, 2010 at 2:12 PM, E=
ric Covener <cove=
ner@gmail.com
>
wrote:

x #ccc solid;padding-left:1ex;">
> I have been trying t=
o work with mod_setenvif module to start but have not

> made any progress and thus seeking your help.



Show us what you have, and what it does.



--

Eric Covener





------------------------------------------------------------ ---------

The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL: lank">http://httpd.apache.org/userslist.html> for more info.

To unsubscribe, e-mail: g">users-unsubscribe@httpd.apache.org

=A0 " =A0 from the digest: @httpd.apache.org">users-digest-unsubscribe@httpd.apache.org

For additional commands, e-mail: org">users-help@httpd.apache.org






--0015175cb4ba6201540481d79367--

Re: Conditionally Setting HTTP Response Header

am 15.03.2010 15:26:59 von Eric Covener

On Mon, Mar 15, 2010 at 10:19 AM, Anurag Kapur wrote:
> I have been trying configurations like the following:
> SetEnvIf response Cache-Control !"^max-age*$"
> test=ThisShouldDisplayInXwsField
> Header append X-ws test

Re-reading OP, it sounds like you just want Expires. I don't think it
blows away existing headers.

I don't think the syntax is right on either one, was this verbatim
from something you tested? Shouldn't this just be:

SetEnvIf Cache-Control .+ cc_set=1
Header set Cache-Control ... env=cc_set


--
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Conditionally Setting HTTP Response Header

am 15.03.2010 15:59:17 von Anurag Kapur

--000325557fa616da830481d8208f
Content-Type: text/plain; charset=ISO-8859-1

Below is exactly what I tried:

SetEnvIfNoCase response Cache-Control .+ cc_set=123
Header append X-ws "test" env=cc_set

Expected output: If response does not have Cache-Control set, the X-ws field
should display the text "test".
Actual output: X-ws field did not display the text "test"

Note: I realized the problem with the syntax I was using after you pointed
it out and tried the above after fixing it (I think).

-Anurag

On Mon, Mar 15, 2010 at 2:26 PM, Eric Covener wrote:

> On Mon, Mar 15, 2010 at 10:19 AM, Anurag Kapur
> wrote:
> > I have been trying configurations like the following:
> > SetEnvIf response Cache-Control !"^max-age*$"
> > test=ThisShouldDisplayInXwsField
> > Header append X-ws test
>
> Re-reading OP, it sounds like you just want Expires. I don't think it
> blows away existing headers.
>
> I don't think the syntax is right on either one, was this verbatim
> from something you tested? Shouldn't this just be:
>
> SetEnvIf Cache-Control .+ cc_set=1
> Header set Cache-Control ... env=cc_set
>
>
> --
> Eric Covener
> covener@gmail.com
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

--000325557fa616da830481d8208f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Below is exactly what I tried:


   SetEnvIfNoCas=
e response Cache-Control .+ cc_set=3D123
   Header append X-w=
s "test" env=3Dcc_set

Expected output: I=
f response does not have Cache-Control set, the X-ws field should display t=
he text "test".

Actual output: X-ws field did not display the text "test" iv>

Note: I realized the problem with the syntax I was u=
sing after you pointed it out and tried the above after fixing it (I think)=
..



-Anurag

On Mon, Mar 15, 20=
10 at 2:26 PM, Eric Covener < @gmail.com">covener@gmail.com> wrote:
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex;">
On Mon, Mar 15, 2010 at 10:19 AM, Anurag Kapur < f=3D"mailto:anuragkapur@gmail.com">anuragkapur@gmail.com> wrote:

> I have been trying configurations like the following:

> SetEnvIf response Cache-Control !"^max-age*$"

> test=3DThisShouldDisplayInXwsField

> Header append X-ws test



Re-reading OP, it sounds like you just want Expires. I don't thin=
k it

blows away existing headers.



I don't think the syntax is right on either one, was this verbatim

from something you tested? =A0Shouldn't this just be:



SetEnvIf Cache-Control .+ cc_set=3D1

Header set Cache-Control ... =A0env=3Dcc_set





--

Eric Covener





------------------------------------------------------------ ---------

The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL: lank">http://httpd.apache.org/userslist.html> for more info.

To unsubscribe, e-mail: g">users-unsubscribe@httpd.apache.org

=A0 " =A0 from the digest: @httpd.apache.org">users-digest-unsubscribe@httpd.apache.org

For additional commands, e-mail: org">users-help@httpd.apache.org






--000325557fa616da830481d8208f--

Re: Conditionally Setting HTTP Response Header

am 15.03.2010 16:02:55 von Eric Covener

On Mon, Mar 15, 2010 at 10:59 AM, Anurag Kapur wrot=
e:
> Below is exactly what I tried:
>    SetEnvIfNoCase response Cache-Control .+ cc_set=3D123
>    Header append X-ws "test" env=3Dcc_set
> Expected output: If response does not have Cache-Control set, the X-ws fi=
eld
> should display the text "test".
> Actual output: X-ws field did not display the text "test"
> Note: I realized the problem with the syntax I was using after you pointe=
d
> it out and tried the above after fixing it (I think).
> -Anurag

What is "response" doing there?

SetEnvIfNoCase attribute regex [!]env-variable[=3Dvalue]
[[!]env-variable[=3Dvalue]] ...


--=20
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Conditionally Setting HTTP Response Header

am 15.03.2010 16:15:32 von Anurag Kapur

--000325559b1e2b39880481d85a05
Content-Type: text/plain; charset=ISO-8859-1

I saw it used here
http://mail-archives.apache.org/mod_mbox/httpd-dev/200609.mb ox/%3C450543D6.80505@web.turner.com%3E


I thought it is needed to differentiate a field set in the response header
from that in the request header. But after reading the documentation again,
I see it says:
An HTTP request header field (see
RFC2616for more information
about these); for example:
Host, User-Agent, Referer, and Accept-Language. A regular expression may be
used to specify a set of request headers.
http://httpd.apache.org/docs/2.0/mod/mod_setenvif.html#seten vif

Which means I can use only request header fields (Am I right?). However,
what I am looking to do is conditionally set an environment variable based
on the "response" header (not request header), so that I know if I have to
append or unset a certain field in the response header.

Unless I am getting this wrong, is there any other way of doing this?

Thanks
Anurag

On Mon, Mar 15, 2010 at 3:02 PM, Eric Covener wrote:

> On Mon, Mar 15, 2010 at 10:59 AM, Anurag Kapur
> wrote:
> > Below is exactly what I tried:
> > SetEnvIfNoCase response Cache-Control .+ cc_set=123
> > Header append X-ws "test" env=cc_set
> > Expected output: If response does not have Cache-Control set, the X-ws
> field
> > should display the text "test".
> > Actual output: X-ws field did not display the text "test"
> > Note: I realized the problem with the syntax I was using after you
> pointed
> > it out and tried the above after fixing it (I think).
> > -Anurag
>
> What is "response" doing there?
>
> SetEnvIfNoCase attribute regex [!]env-variable[=value]
> [[!]env-variable[=value]] ...
>
>
> --
> Eric Covener
> covener@gmail.com
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

--000325559b1e2b39880481d85a05
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I saw it used here=A0 tpd-dev/200609.mbox/%3C450543D6.80505@web.turner.com%3E">htt p://mail-archiv=
es.apache.org/mod_mbox/httpd-dev/200609.mbox/%3C450543D6.805 05@web.turner.c=
om%3E
=A0



I thought it is needed to differentiate a field set in the r=
esponse header from that in the request header. But after reading the docum=
entation again, I see it says:
An HTTP request header field (see =

for more information about these); for example: Host,
User-Agent, Referer, and=20
Accept-Language. A regular expression may be
used to specify a set of request headers.
ttpd.apache.org/docs/2.0/mod/mod_setenvif.html#setenvif">htt p://httpd.apach=
e.org/docs/2.0/mod/mod_setenvif.html#setenvif


Which means I can use only request header fields (Am I right?). However, wh=
at I am looking to do is conditionally set an environment variable based on=
the "response" header (not request header), so that I know if I =
have to append or unset a certain field in the response header.


Unless I am getting this wrong, is there any other way =
of doing this?

Thanks
Anurag

class=3D"gmail_quote">On Mon, Mar 15, 2010 at 3:02 PM, Eric Covener dir=3D"ltr"><&=
gt;
wrote:

x #ccc solid;padding-left:1ex;">
On Mon, Mar 15, 2010 at 1=
0:59 AM, Anurag Kapur <anuragka=
pur@gmail.com
> wrote:


> Below is exactly what I tried:

>    SetEnvIfNoCase response Cache-Control .+ cc_set=3D123

>    Header append X-ws "test" env=3Dcc_set

> Expected output: If response does not have Cache-Control set, the X-ws=
field

> should display the text "test".

> Actual output: X-ws field did not display the text "test" >
> Note: I realized the problem with the syntax I was using after you poi=
nted

> it out and tried the above after fixing it (I think).

> -Anurag



What is "response" doing there?



SetEnvIfNoCase attribute regex [!]env-variable[=3Dvalue]

[[!]env-variable[=3Dvalue]] ...





--

Eric Covener





------------------------------------------------------------ ---------

The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL: lank">http://httpd.apache.org/userslist.html> for more info.

To unsubscribe, e-mail: g">users-unsubscribe@httpd.apache.org

=A0 " =A0 from the digest: @httpd.apache.org">users-digest-unsubscribe@httpd.apache.org

For additional commands, e-mail: org">users-help@httpd.apache.org






--000325559b1e2b39880481d85a05--

Re: Conditionally Setting HTTP Response Header

am 15.03.2010 16:41:12 von Eric Covener

On Mon, Mar 15, 2010 at 11:15 AM, Anurag Kapur wrot=
e:
> I saw it used
> here=A0http://mail-archives.apache.org/mod_mbox/httpd-dev/20 0609.mbox/%3C=
450543D6.80505@web.turner.com%3E
> I thought it is needed to differentiate a field set in the response heade=
r
> from that in the request header. But after reading the documentation agai=
n,
> I see it says:
> An HTTP request header field (see RFC2616 for more information about thes=
e);
> for example: Host, User-Agent, Referer, and Accept-Language. A regular
> expression may be used to specify a set of request headers.
> http://httpd.apache.org/docs/2.0/mod/mod_setenvif.html#seten vif
> Which means I can use only request header fields (Am I right?). However,
> what I am looking to do is conditionally set an environment variable base=
d
> on the "response" header (not request header), so that I know if I have t=
o
> append or unset a certain field in the response header.
> Unless I am getting this wrong, is there any other way of doing this?

Not sure, but the code you reference is not in Apache HTTP Server 2.2.x

--=20
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org